package ASTInterpreter;


import stone.BasicParser;
import stone.ClassParser;
import stone.ParseException;
import stone.CodeDialog;
import stone.Lexer;
import stone.Token;
import stone.ast.ASTree;
import stone.ast.NullStmnt;
import stone.Natives;


public class EnvOptInterpreter {

	public static void main(String[] args) throws ParseException {
		run(new ClassParser(), new Natives().environment(new ResizableArrayEnv()));
	}

	public static void run(BasicParser bp, Environment env) throws ParseException{
		Lexer lexer = new Lexer(new CodeDialog());
		while(lexer.peek(0) != Token.EOF) {
			ASTree t = bp.parse(lexer);
			if (!(t instanceof NullStmnt)) {
				t.lookup(env.symbols());
				Object r = t.eval(env);
				System.out.println("=> " + r);
			}
		}
	}

}